package com.vca.front.controller;

import com.vca.common.page.CommonPage;
import com.vca.common.request.PageParamRequest;
import com.vca.common.response.ShopsResponse;
import com.vca.common.response.ShopListResponse;
import com.vca.common.response.ShopResponse;
import com.vca.common.result.CommonResult;
import com.vca.service.service.VcaProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品控制器
 *
 * @author chenbing
 * @date 2022/11/16   15:16
 */
@Slf4j
@RestController("VcaProductController")
@RequestMapping("api/front/product")
@Api(tags = "商品控制器")
public class VcaProductController {
    @Autowired
    private VcaProductService vcaProductService;

    /**
     * @Description:商品分页列表
     * @Author: chenBing
     * @Date: 2022/11/16
     */
    @ApiOperation(value = "商品分页列表")
    @GetMapping(value = "/page/list/{type}")
    public CommonResult<CommonPage<ShopsResponse>> shopListPage(
            @ApiParam(value = "商品类型 0=souvenir 1=publication 2=giftcertificate")
            @PathVariable(value = "type") Integer type,
            @ModelAttribute PageParamRequest request,
            @RequestHeader(value = "language",required = false) String language
    ) {
        return CommonResult.success(CommonPage.restPage(vcaProductService.shopListPage(language,request,type)));
//        return CommonResult.success(CommonPage.restPage(vcaProductService.publicationListPage(request)));
    }

    /**
     * @Description:商品详情
     * @Author: chenBing
     * @Date: 2022/11/17
     */
    @ApiOperation(value = "商品详情")
    @GetMapping(value = "/info/{shopId}")
    public CommonResult<ShopResponse> shopInfo(
            @RequestHeader(value="language" ,required = false) String language,
            @PathVariable(value = "shopId") Integer shopId
    ) {
        return CommonResult.success(vcaProductService.shopInfo(language,shopId));
    }

    /**
    * @Description:商品列表
    * @Author: chenBing
    * @Date: 2022/11/17
    */
    @ApiOperation(value = "商品列表")
    @GetMapping(value = "/list")
    public CommonResult<ShopListResponse> shopList(@RequestHeader(value = "language",required = false) String language){
        return CommonResult.success(vcaProductService.shopList(language));
    }

}
